import request from '@/utils/request';

// 定义请求地址的枚举
enum Api {
  GetPermissionList = '/admin.Menu/list', // 获取权限列表数据
  RemovePermission = '/admin.Menu/dele', // 移除
  SavePermission = '/admin.Menu/add', // 添加
  UpdatePermission = '/admin.Menu/edit', // 更新
  disableApi = '/admin.Menu/disable',//禁用
}

/**
 * 获取权限列表
 * @returns PermissionListResponseModel
 */
export const getPermissionListApi = () => {
  return request.get<any, any>(Api.GetPermissionList);
};

/**
 * 删除权限
 * @param id 权限id
 * @returns null
 */
export const removePermissionApi = (id: string) => {
  return request.get<any, any>(Api.RemovePermission +`?admin_menu_id=${id}`);
};

/**
 * 添加或更新权限
 * @param permission 权限对象 
 * @returns null
 */
export const saveOrUpdatePermissionApi = (permission: any) => {
  return request.post<any, null>(permission.type==1 ? Api.UpdatePermission : Api.SavePermission, permission);
};

export const reqGetDisabled = (admin_menu_id:any,is_disable:any)=>{
  return request.get<any,any>(Api.disableApi + `?admin_menu_id=${admin_menu_id}&is_disable=${is_disable}`)
} 